import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import '../../helper/channelHelper.dart';
import '../../widgets/IconWidget.dart';

import '../../model/shipuse.dart';

import '../../model/user.dart';

class ShipUseAuthority {
  static bool SdZby(User u1) {
    //if(u1.Authority.indexOf("水调值班员")>-1)
    //return true;
    return false;
  }

  static bool DcZby(User u1) {
    //if(u1.Authority.indexOf("电厂值班员")>-1)
    //return true;

    return false;
  }

  static bool IfQianZi(ShipUse s1, User u1) {
    //添加签字规则验证

    if (s1.State == 2 && s1.SYUserID == u1.Guid) return true;

    if (s1.State == 3 && (s1.HDUserID == u1.Guid)) return true;

    if (s1.State == 4 && (s1.LDUserID == u1.Guid)) return true;

    return false;
  }

  static String QianZiTitle(ShipUse s1, User u1) {
    if (s1.HDUserID == u1.Guid) {
      return "河道部负责人签字";
    }

    if (s1.SYUserID == u1.Guid) {
      return "实业公司负责人签字";
    }

    if (s1.LDUserID == u1.Guid) {
      return "公司分管领导签字";
    }

    return "签字版";
  }

  static bool IfQianZi2(ShipUse s1, User u1) {
    return false;
  }

  static bool IfHuiZhi(User u1) {
    print(u1.Authority);
    if (u1.Authority.contains("船艇管理")) return true;

    return false;
  }

  static Widget GetShipTitle(ShipUse X1) {
    return ListTile(
      leading: IconWidget.ShipImage(),
      title: Text(
        "用船审批" 
      ),
      onLongPress: () {
        Clipboard.setData(ClipboardData(
            text: 'http://47.95.205.213:8001/shipuse/details/' + X1.Guid));
        ChannelHelper.showToast("已将该申请网址复制到剪切板！");
      },
    );
  }
}
